﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using Mobile.MainService;
using System.Web.Security;

namespace Mobile.Models
{
    public class Queue
    {
        Service sv = new Service();

        [Required]
        [Key]
        public string partyID { get; set; }

        public List<Song> SongList
        {
            get
            {
                List<Song> Songs = new List<Song>();
                foreach (QueueData qd in sv.GetQueue(partyID).ToList())
                {
                    Songs.Add(new Song { ID = qd.Song.SongID, Title = qd.Song.Title, Artist = qd.Song.Artist, UpVotes = qd.UpVotes });
                }
                Songs.Sort(Song.CompareByUpvotes);
                return Songs;
            }
            set
            {
                SongList = value; 
            }
        }

        public Song getNowPlaying()
        {
            SongData sd = sv.GetNowPlaying(partyID);
            Song nowPlayingSong = new Song { ID = sd.SongID, Artist = sd.Artist, Title = sd.Title, UpVotes = 0};
            return nowPlayingSong;
        }

       
    }
}